// src/api/cors.js

import apiClient from './index';

/**
 * 获取存储桶的CORS规则
 * @param {string} bucketName - 桶名称
 * @returns {Promise<Array>} - CORS规则数组
 */
export const getBucketCors = (bucketName) => {
    return apiClient.get(`/api/v1/buckets/${bucketName}/cors`);
};

/**
 * 设置存储桶的CORS规则
 * @param {string} bucketName - 桶名称
 * @param {Array} rules - 新的CORS规则数组
 * @returns {Promise<Object>}
 */
export const setBucketCors = (bucketName, rules) => {
    return apiClient.put(`/api/v1/buckets/${bucketName}/cors`, rules);
};

/**
 * 删除存储桶的所有CORS规则
 * @param {string} bucketName - 桶名称
 * @returns {Promise<Object>}
 */
export const deleteBucketCors = (bucketName) => {
    return apiClient.delete(`/api/v1/buckets/${bucketName}/cors`);
};